#!/usr/bin/env python3
# -*- coding: utf-8 -*-


import requests

URL = "http://www.baidu.com"

response = requests.get(URL)

print(response.text)


encodings = requests.utils.get_encodings_from_content(response.text)
if encodings:
    encoding = encodings[0]
else:
    encoding = response.apparent_encoding
encode_content = response.content.decode(encoding, 'replace')

print(encode_content)